package com.xuecheng.controller;

import com.xuecheng.dto.CoursePreviewDto;
import com.xuecheng.service.CoursePublishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.servlet.ModelAndView;

/**
 * 课程预览，发布
 */
@Controller
public class CoursePublishController {
    @Autowired
    CoursePublishService coursePreviewService;

    @GetMapping("/coursepreview/{courseId}")
    public ModelAndView preview(@PathVariable("courseId") Long courseId){

        //获取课程预览信息
        CoursePreviewDto coursePreviewInfo = coursePreviewService.getCoursePreviewInfo(courseId);
        ModelAndView modelAndView = new ModelAndView();

        modelAndView.addObject("model",coursePreviewInfo);//设置模型数据

        modelAndView.setViewName("course_template");  //设置模板名称
        return modelAndView;
    }

}
